package com.farm.area.dao;

import com.farm.area.pojo.TCustFarmlandDevice;
import com.farm.device.pojo.Device;
import com.farm.opjo.Crops;
import com.farm.shop.pojo.CustDevice;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 陈哲
 * @create 2020/10/16 14:27
 */
@Repository
public interface FarmLandDeviceMapper extends Mapper<TCustFarmlandDevice> {
    @Select("select * from t_cust_farmland_device where cdid = #{cdid}")
    TCustFarmlandDevice selectByCdid(Integer cdid);
    @Update("update t_cust_farmland_device set status=#{status} where id=#{id}")
    int updateStatusByFarmLandDevice(TCustFarmlandDevice farmlandDevice);
    @Select("SELECT cfc.grow_stage growStage,c.* from t_cust_farmland_crops cfc, t_crops c where cfc.crops_id=c.id and cfc.farmland_id=#{farmlandId}")
    Crops findCropsByFarmLandId(Integer farmlandId);
    @Select("SELECT cd.* from t_cust_farmland_device cfd, t_cust_device cd where cfd.cdid=cd.did and cfd.farmland_id=#{farmlandId}")
    List<CustDevice> findDevicesByFarmLandId(Integer farmlandId);
    @Select("select * from t_device where id=#{did}")
    Device findBydid(Integer did);
}
